#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;

const int k = 32;
const int numberOfTests = 1000;
const int numberOfSamples = 10000;

int main(int argc, char *argv[])
{
    unsigned int timeValue = time(NULL);
    char buffer[100];

	for(int i = 0 ; i < numberOfTests ; ++i) {
	    srand(timeValue + i);
        
        sprintf(buffer, "./tests/%d.txt", i);
	    
	    FILE *pFile = fopen (buffer, "w");
        if (pFile!=NULL) {
            
            sprintf(buffer, "%d\n", k);
            fprintf(pFile, "%s", buffer);
            
            for(int j = 0 ; j < k ; ++j) {
                if(rand() % 2) {
                    fprintf(pFile, "0");
                }
                else {
                    fprintf(pFile, "1");
                }
            }
            fprintf(pFile, "\n");
            for(int j = 0 ; j < k ; ++j) {
                if(rand() % 2) {
                    fprintf(pFile, "0");
                }
                else {
                    fprintf(pFile, "1");
                }
            }
            fprintf(pFile, "\n");
        
            fclose (pFile);
        }
	}
	
	// Wygenerowanie skryptu testującego
	FILE *pFile = fopen ("./testskrypt.sh", "w");
    if (pFile!=NULL) {
        //fprintf(pFile, "g++ Tausworth.cpp -o Tausworth\n");
        for(int i = 0 ; i < numberOfTests ; ++i) {
            fprintf(pFile, "./Tausworth %d < ./tests/%d.txt > ./out/%d.txt\n", numberOfSamples, i, i);
        }
        for(int i = 0 ; i < numberOfTests ; ++i) {
            fprintf(pFile, "./StatystykiTestowe 32 < ./out/%d.txt > ./stats/%d.txt\n", i, i);
        }
        fclose (pFile);
    }

	return 0;
}
